snapshot: Pass the clip region to the snapshot
authorBenjamin Otte <otte@redhat.com>
Thu, 17 Nov 2016 01:14:10 +0000 (02:14 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 17 Nov 2016 01:14:10 +0000 (02:14 +0100)
gtk/gtksnapshot.c
gtk/gtksnapshotprivate.h
gtk/gtkwidget.c

index 22752ddaf705cdb746a589c2ac44c4c89584f0fc..a86df11d8967c37bab72734aa265c1f64a6eccf7 100644 (file)
@@ -58,12 +58,14 @@ gtk_snapshot_state_set_transform (GtkSnapshotState        *state,
 }
 
 void
-gtk_snapshot_init (GtkSnapshot *state,
-                   GskRenderer *renderer)
+gtk_snapshot_init (GtkSnapshot          *snapshot,
+                   GskRenderer          *renderer,
+                   const cairo_region_t *clip)
 {
-  state->state = NULL;
-  state->root = NULL;
-  state->renderer = renderer;
+  snapshot->state = NULL;
+  snapshot->root = NULL;
+  snapshot->renderer = renderer;
+  snapshot->clip_region = clip;
 }
 
 GskRenderNode *
index 084331b525cd8033afb9af038f8e70aa5e5aebb8..c9899d004f029ef70b12394c63ad19d4f0b8f740 100644 (file)
@@ -37,10 +37,12 @@ struct _GtkSnapshot {
 
   GskRenderNode         *root;
   GskRenderer           *renderer;
+  const cairo_region_t  *clip_region;
 };
 
 void            gtk_snapshot_init               (GtkSnapshot             *state,
-                                                 GskRenderer             *renderer);
+                                                 GskRenderer             *renderer,
+                                                 const cairo_region_t    *clip);
 GskRenderNode * gtk_snapshot_finish             (GtkSnapshot             *state);
 
 static inline const graphene_matrix_t *
index 9ed013a66ca87bfb013bb8395e6cf0a5f35ab61c..7e4c56d56e8c29c8ed4e88cdb6a62e7a81d15a6a 100644 (file)
@@ -6409,6 +6409,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
           GtkSnapshot snapshot;
           GskRenderer *fallback;
           graphene_rect_t viewport;
+          cairo_region_t *clip;
           GskRenderNode *node;
 
           graphene_rect_init (&viewport,
@@ -6416,8 +6417,13 @@ gtk_widget_draw_internal (GtkWidget *widget,
                               widget->priv->allocation.y - widget->priv->clip.y,
                               widget->priv->clip.width,
                               widget->priv->clip.height);
+          clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
+                                                widget->priv->allocation.x - widget->priv->clip.x,
+                                                widget->priv->allocation.y - widget->priv->clip.y,
+                                                widget->priv->clip.width,
+                                                widget->priv->clip.height});
           fallback = gsk_renderer_create_fallback (renderer, &viewport, cr);
-          gtk_snapshot_init (&snapshot, renderer);
+          gtk_snapshot_init (&snapshot, renderer, clip);
           gtk_widget_snapshot (widget, &snapshot);
           node = gtk_snapshot_finish (&snapshot);
           if (node != NULL)
@@ -6426,6 +6432,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
               gsk_render_node_unref (node);
             }
 
+          cairo_region_destroy (clip);
           g_object_unref (fallback);
         }
       else
@@ -15713,7 +15720,7 @@ gtk_widget_render (GtkWidget            *widget,
   if (renderer == NULL)
     return;
 
-  gtk_snapshot_init (&snapshot, renderer);
+  gtk_snapshot_init (&snapshot, renderer, region);
   gtk_widget_snapshot (widget, &snapshot);
   root = gtk_snapshot_finish (&snapshot);
   if (root == NULL)